angular.module('myApp').controller('update', ["$scope", "$http", "$location", "$stateParams","$state",function ($scope, $http, $location,$stateParams,$state) {
    var c;
    var d;
    <!-- 获取班级信息-->
    $http({
        method: 'post',
        url: '/classInformation',
    }).then(function (data) {
        $scope.Class = data.data
    });
    <!-- 获取年级信息-->
    $http({
        method: 'post',
        url: '/gradeInformation',
    }).then(function (data) {
        $scope.grade = data.data;
    });
    <!-- 获取班主任信息-->
    $http({
        method: 'post',
        url: '/teacherInformation',
    }).then(function (data) {
        $scope.teacher = data.data;
    });
    <!-- 获取学生信息-->
    $http({
        method: 'post',
        url: '/theQuery',
        data: {
            student_id:$stateParams.id
        }
    }).then(function (data) {
        $scope.id = data.data.id;
        $scope.name = data.data.name;
        c = data.data.sex;
        console.log(data.data);
        $scope.age = data.data.age;
        $scope.sfzh = data.data.sfzh;
        $scope.Class1=""+data.data.banji_id;
        $scope.grade1=""+data.data.nianji_id;
        $scope.teacher1=""+data.data.banzhuren_id;
        if (c == "1") {
           // $scope.b = 'true';
            $scope.sexa = '1';
        } else if (c == "0") {
            //$scope.a = 'true';
            $scope.sexa = '0';
        }

    });
    $scope.updata = function () {
        console.log($scope.sexa);
        $http({
            method: 'post',
            url: '/updata',
            data: {
                student: {
                    id: $scope.id,
                    name: $scope.name,
                    sex: $scope.sexa,
                    age: $scope.age,
                    sfzh: $scope.sfzh,
                    banji_id: $scope.Class1,
                    nianji_id: $scope.grade1,
                    banzhuren_id: $scope.guideMember1
                }
            }
        }).then(function (data) {
            if (data.data.state == "ok") {
                $state.go('home');
            }
        })
    }
}]);